home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{5A65A9C0-089F-11D2-88AD-0000B45C4CF6}#1.2#0"; "EASYX.OCX"
- Begin VB.Form Form1
- Caption = "Form1"
- ClientHeight = 3195
- ClientLeft = 60
- ClientTop = 345
- ClientWidth = 4680
- Icon = "Form1.frx":0000
- LinkTopic = "Form1"
- ScaleHeight = 3195
- ScaleWidth = 4680
- StartUpPosition = 3 'Windows Default
- Begin PROJECTEXLibCtl.EasyX EasyX
- Left = 960
- OleObjectBlob = "Form1.frx":014A
- Top = 120
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- Dim CursorSprite As Long
- Dim ButtonSprite(1) As Long
- Dim CursorSurface As Long
- Dim ButtonSurface As Long
- Const ButtonWidth As Long = 100
- Const ButtonHeight As Long = 50
- Const ButtonUpperX As Long = 150
- Const ButtonUpperY As Long = 120
- Const CursorWidth As Long = 25
- Const CursorHeight As Long = 25
- Private Sub RunMain()
- Static ButtonState As Long
- Static PointX As Long
- Static PointY As Long
- Dim rt As Long
- Dim X As Long, Y As Long, Button As Long
- Dim SpriteFrame As Long
- Dim Hit As Boolean
- Static WasClicked As Boolean
- 'reset values
- X = 0
- Y = 0
- Button = 0
- Hit = False
- 'Get the mouse positions
- rt = EasyX.GetMouseState(X, Y, Button)
- If rt = EX_DEVICENOTACQUIRED Then
- EasyX.AcquireMouse
- End If
-
- PointX = PointX + X
- PointY = PointY + Y
- 'end on right click
- If Button = EX_RIGHTBUTTON Then
- EasyX.EndDirectX
- Unload Me
- Exit Do
- End If
- 'Check the borders, so the mouse will stay on screen
- If PointX < 0 Then
- PointX = 0
- ElseIf (PointX + CursorWidth) > 640 Then
- PointX = 640 - CursorWidth
- End If
- If PointY < 0 Then
- PointY = 0
- ElseIf (PointY + CursorHeight) > 400 Then
- PointY = 400 - CursorHeight
- End If
-
- 'check if the mouse is over the button
- If (PointX + CursorWidth) > ButtonUpperX And PointX < (ButtonUpperX + ButtonWidth) _
- And (PointY + CursorHeight) > ButtonUpperY And PointY < (ButtonUpperY + ButtonHeight) Then 'it
- s a hit
- Hit = True
- SpriteFrame = 1
- Else
- SpriteFrame = 0
- WasClicked = False
- End If
-
- 'check for click
- If Button <> ButtonState Then
- ButtonState = Button
- WasClicked = False
- End If
- 'beep if hit and left button is clicked
- If Hit And ButtonState = EX_LEFTBUTTON And (Not WasClicked) Then
- Beep
- WasClicked = True
- End If
- 'Now draw it all
- 'fill the surfac first with black
- EasyX.FillSurface 25, -1
- 'the button first
- EasyX.DrawSprite ButtonUpperX, ButtonUpperY, ButtonWidth, ButtonHeight, ButtonSprite(SpriteFrame)
- 'the cursor
- EasyX.DrawSprite PointX, PointY, CursorWidth, CursorHeight, CursorSprite
- 'flip it
- EasyX.FlipSurface
- DoEvents
- End Sub
- Private Sub Form_Load()
- Dim rt As Long
- Dim AppPath As String
- t forget this
- EasyX.Window = Me.hWnd
- '''''''''''''''''''''
- AppPath = App.Path & "\"
- 'Set the direct draw screen
- rt = EasyX.InitDirectDraw(640, 400, 8)
- If rt <> EX_OK Then 'it didn
- t work try an otheer mode
- EasyX.EndDirectX
- MsgBox "Direct draw could not initialize", vbOKOnly, "Failure"
- Exit Sub
- End If
- 'Set the mouse
- rt = EasyX.InitDirectInput()
- If rt <> EX_OK Then
- EasyX.EndDirectX
- MsgBox "Direct input could not initialize", vbOKOnly, "Failure"
- Exit Sub
- End If
- 'Create the mouse
- rt = EasyX.CreateMouse()
- If rt <> EX_OK Then
- EasyX.EndDirectX
- MsgBox "Mouse could not be created", vbOKOnly, "Failure"
- Exit Sub
- End If
- 'acquire it
- EasyX.AcquireMouse
- CursorSurface = EasyX.LoadBitmapFile(AppPath & "cursor.bmp", 0)
- 'first surface so it must be 0
- If CursorSurface <> 0 Then
- EasyX.EndDirectX
- MsgBox "Graphics could not be loaded", vbOKOnly, "Failure"
- Exit Sub
- End If
- ButtonSurface = EasyX.LoadBitmapFile(AppPath & "buttons.bmp", RGB(255, 255, 255))
- 'Second surface so it must be 1
- If ButtonSurface <> 1 Then
- EasyX.EndDirectX
- MsgBox "Graphics could not be loaded", vbOKOnly, "Failure"
- Exit Sub
- End If
- 'make the sprites
- 'first the buttons
- ButtonSprite(0) = EasyX.MakeSprite(0, 0, 100, 50, ButtonSurface)
- ButtonSprite(1) = EasyX.MakeSprite(0, 50, 100, 100, ButtonSurface)
- 'and then the cursor
- CursorSprite = EasyX.MakeSprite(0, 0, 25, 25, CursorSurface)
- RunMain
- End Sub
-